 package scripting.event;


import client.MapleCharacter;
import client.MapleClient;
import client.inventory.Equip;
import client.inventory.Item;
import client.inventory.MapleInventoryType;
import com.alibaba.druid.pool.DruidPooledConnection;
import constants.ItemConstants;
import database.DatabaseConnection;
import handling.channel.ChannelServer;
import handling.world.WorldBroadcastService;
import handling.world.party.MapleParty;
import handling.world.party.MaplePartyCharacter;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import server.MapleInventoryManipulator;
import server.MapleItemInformationProvider;
import server.RankingTop;
import server.Timer;
import server.events.MapleEvent;
import server.events.MapleEventType;
import server.life.MapleLifeFactory;
import server.life.MapleMonster;
import server.life.MapleMonsterInformationProvider;
import server.life.OverrideMonsterStats;
import server.maps.*;
import server.squad.MapleSquad;
import tools.MaplePacketCreator;
import tools.Randomizer;
import tools.packet.UIPacket;

import javax.script.Invocable;
import javax.script.ScriptException;
import java.awt.*;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import java.util.List;
import java.util.concurrent.ScheduledFuture;

 public class EventManager {
/*  46 */   private static final Logger log = LogManager.getLogger(EventManager.class);
/*  47 */   private static final int[] eventChannel = new int[2];
   private final Invocable iv;
   private final int channel;
/*  50 */   private final Map<String, EventInstanceManager> instances = new WeakHashMap<>();
/*  51 */   private final Properties props = new Properties();



   private final String name;



   public EventManager(ChannelServer cserv, Invocable iv, String name) {
/*  60 */     this.iv = iv;
/*  61 */     this.channel = cserv.getChannel();
/*  62 */     this.name = name;
   }


   public void cancel() {
     try {
/*  68 */       this.iv.invokeFunction("cancelSchedule", new Object[] { null });
/*  69 */     } catch (Exception ex) {
/*  70 */       log.error("Event name : " + this.name + ", method Name : cancelSchedule:\r\n" + ex);
     }
   }






   public ScheduledFuture<?> schedule(String methodName, long delay) {
/*  80 */     return Timer.EventTimer.getInstance().schedule(() -> {
           try {
             this.iv.invokeFunction(methodName, new Object[] { null });
/*  83 */           } catch (Exception ex) {
             log.error("Event name : " + this.name + ", method Name : " + methodName + ":\r\n" + ex);
           }
         },delay);
   }







   public ScheduledFuture<?> schedule(String methodName, long delay, EventInstanceManager eim) {
/*  96 */     return Timer.EventTimer.getInstance().schedule(() -> {
           try {
             this.iv.invokeFunction(methodName, new Object[] { eim });
/*  99 */           } catch (Exception ex) {
             log.error("Event name : " + this.name + ", method Name : " + methodName + ":\r\n" + ex);
           }
         },delay);
   }






   public ScheduledFuture<?> scheduleAtTimestamp(String methodName, long timestamp) {
/* 111 */     return Timer.EventTimer.getInstance().scheduleAtTimestamp(() -> {
           try {
             this.iv.invokeFunction(methodName, new Object[] { null });
/* 114 */           } catch (ScriptException|NoSuchMethodException ex) {
             log.error("Event name : " + this.name + ", method Name : " + methodName + ":\r\n" + ex);
           }
         },timestamp);
   }

   public ScheduledFuture<?> register(String methodName, long timestamp) {
/* 121 */     return Timer.EventTimer.getInstance().register(() -> {
           try {
             this.iv.invokeFunction(methodName, new Object[] { null });
/* 124 */           } catch (ScriptException|NoSuchMethodException ex) {
             log.error("Event name : " + this.name + ", method Name : " + methodName + ":\r\n" + ex);
           }
         },timestamp);
   }

   public void cancelRegister() {
     try {
/* 132 */       this.iv.invokeFunction("cancelRegister", new Object[] { null });
/* 133 */     } catch (ScriptException|NoSuchMethodException ex) {
/* 134 */       System.out.println("Event name : " + this.name + ", method Name : cancelRegister:\n" + ex);
     }
   }

   public void start(String function, Object obj) {
     try {
/* 140 */       this.iv.invokeFunction(function, new Object[] { obj });
/* 141 */     } catch (ScriptException|NoSuchMethodException ex) {
/* 142 */       System.out.println("Event name : " + this.name + ", method Name : start:\n" + ex);
     }
   }




   public int getChannel() {
/* 150 */     return this.channel;
   }




   public ChannelServer getChannelServer() {
/* 157 */     return ChannelServer.getInstance(this.channel);
   }





   public EventInstanceManager getInstance(String name) {
/* 165 */     return this.instances.get(name);
   }




   public Collection<EventInstanceManager> getInstances() {
/* 172 */     return Collections.unmodifiableCollection(this.instances.values());
   }





   public EventInstanceManager newInstance(String name) {
/* 180 */     EventInstanceManager ret = new EventInstanceManager(this, name, this.channel);
/* 181 */     this.instances.put(name, ret);
/* 182 */     return ret;
   }




   public void disposeInstance(String name) {
/* 189 */     this.instances.remove(name);
/* 190 */     if (getProperty("state") != null && this.instances.isEmpty()) {
/* 191 */       setProperty("state", "0");
     }
/* 193 */     if (getProperty("leader") != null && this.instances.isEmpty() && getProperty("leader").equals("false")) {
/* 194 */       setProperty("leader", "true");
     }
/* 196 */     if (this.name.equals("CWKPQ")) {
/* 197 */       MapleSquad squad = ChannelServer.getInstance(this.channel).getMapleSquad("CWKPQ");
/* 198 */       if (squad != null) {
/* 199 */         squad.clear();
/* 200 */         squad.copy();
       }
     }
   }




   public Invocable getIv() {
/* 209 */     return this.iv;
   }





   public void setProperty(String key, String value) {
/* 217 */     this.props.setProperty(key, value);
   }





   public String getProperty(String key) {
/* 225 */     return this.props.getProperty(key);
   }




   public final Properties getProperties() {
/* 232 */     return this.props;
   }

   public final void setObjectProperty(Object obj1, Object obj2) {
/* 236 */     this.props.put(obj1, obj2);
   }

   public final Object getObjectProperty(Object obj) {
/* 240 */     return this.props.get(obj);
   }




   public String getName() {
/* 247 */     return this.name;
   }


   public void startInstance() {
     try {
/* 253 */       this.iv.invokeFunction("setup", new Object[] { null });
/* 254 */     } catch (Exception ex) {
/* 255 */       log.error("Event name : " + this.name + ", method Name : setup:\r\n" + ex);
     }
   }





   public void startInstance_Solo(String mapid, MapleCharacter chr) {
     try {
/* 265 */       EventInstanceManager eim = (EventInstanceManager)this.iv.invokeFunction("setup", new Object[] { mapid });
/* 266 */       eim.registerPlayer(chr);
/* 267 */     } catch (Exception ex) {
/* 268 */       log.error("Event name : " + this.name + ", method Name : setup:\r\n" + ex);
     }
   }





   public void startInstance(String mapid, MapleCharacter chr) {
     try {
/* 278 */       EventInstanceManager eventInstanceManager = (EventInstanceManager)this.iv.invokeFunction("setup", new Object[] { mapid });
/* 279 */     } catch (Exception ex) {
/* 280 */       log.error("Event name : " + this.name + ", method Name : setup:\r\n" + ex);
     }
   }





   public void startInstance_Party(String mapid, MapleCharacter chr) {
     try {
/* 290 */       EventInstanceManager eim = (EventInstanceManager)this.iv.invokeFunction("setup", new Object[] { mapid });
/* 291 */       eim.registerParty(chr.getParty(), chr.getMap());
/* 292 */     } catch (Exception ex) {
/* 293 */       log.error("Event name : " + this.name + ", method Name : setup:\r\n" + ex);
     }
   }

   public void startInstance_Party(String string, MapleCharacter player, int averageLevel) {
     try {
/* 299 */       int totalLevel = 0;
/* 300 */       int memberSize = 0;
/* 301 */       for (MaplePartyCharacter member : player.getParty().getMembers()) {
/* 302 */         if (member.isOnline() && member.getMapid() == player.getMap().getId() && member.getChannel() == player.getMap().getChannel()) {
/* 303 */           totalLevel += member.getLevel();
/* 304 */           memberSize++;
         }
       }
/* 307 */       if (memberSize <= 0) {
         return;
       }
/* 310 */       Object[] arrobject = new Object[2];
/* 311 */       arrobject[0] = string;
/* 312 */       arrobject[1] = Integer.valueOf(Math.min(averageLevel, ((totalLevel /= memberSize) <= 0) ? player.getLevel() : totalLevel));
/* 313 */       EventInstanceManager eim = (EventInstanceManager)this.iv.invokeFunction("setup", arrobject);
/* 314 */       eim.registerParty(player.getParty(), player.getMap());
/* 315 */     } catch (Exception ex) {
/* 316 */       log.error("Event name : " + this.name + ", method Name : setup:\r\n" + ex);
     }
   }







   public void startInstance(MapleCharacter character, String leader) {
     try {
/* 328 */       EventInstanceManager eim = (EventInstanceManager)this.iv.invokeFunction("setup", new Object[] { null });
/* 329 */       eim.registerPlayer(character);
/* 330 */       eim.setProperty("leader", leader);
/* 331 */       eim.setProperty("guildid", String.valueOf(character.getGuildId()));
/* 332 */       setProperty("guildid", String.valueOf(character.getGuildId()));
/* 333 */     } catch (Exception ex) {
/* 334 */       log.error("Event name : " + this.name + ", method Name : setup-Guild:\r\n" + ex);
     }
   }




   public void startInstance_CharID(MapleCharacter character) {
     try {
/* 343 */       EventInstanceManager eim = (EventInstanceManager)this.iv.invokeFunction("setup", new Object[] { Integer.valueOf(character.getId()) });
/* 344 */       eim.registerPlayer(character);
/* 345 */     } catch (Exception ex) {
/* 346 */       log.error("Event name : " + this.name + ", method Name : setup-CharID:\r\n" + ex);
     }
   }




   public void startInstance_CharMapID(MapleCharacter character) {
     try {
/* 355 */       EventInstanceManager eim = (EventInstanceManager)this.iv.invokeFunction("setup", new Object[] { Integer.valueOf(character.getId()), Integer.valueOf(character.getMapId()) });
/* 356 */       eim.registerPlayer(character);
/* 357 */     } catch (Exception ex) {
/* 358 */       log.error("Event name : " + this.name + ", method Name : setup-CharID:\r\n" + ex);
     }
   }




   public void startInstance(MapleCharacter character) {
     try {
/* 367 */       EventInstanceManager eim = (EventInstanceManager)this.iv.invokeFunction("setup", new Object[] { null });
/* 368 */       eim.registerPlayer(character);
/* 369 */     } catch (Exception ex) {
/* 370 */       log.error("Event name : " + this.name + ", method Name : setup-character:\r\n" + ex);
     }
   }







   public void startInstance(MapleParty party, MapleMap map) {
/* 381 */     startInstance(party, map, 255);
   }






   public void startInstance(MapleParty party, MapleMap map, int maxLevel) {
/* 390 */     startInstance(party, map, 255, 0);
   }






   public void startInstance(MapleParty party, MapleMap map, int maxLevel, int questID) {
     try {
/* 400 */       int averageLevel = 0, size = 0;
/* 401 */       for (MaplePartyCharacter mpc : party.getMembers()) {

/* 403 */         if (mpc.isOnline() && mpc.getMapid() == map.getId() && mpc.getChannel() == map.getChannel()) {
/* 404 */           averageLevel += mpc.getLevel();
/* 405 */           size++;
         }
       }
/* 408 */       if (size <= 0) {
         return;
       }
/* 411 */       averageLevel /= size;
/* 412 */       EventInstanceManager eim = (EventInstanceManager)this.iv.invokeFunction("setup", new Object[] { Integer.valueOf(Math.min(maxLevel, averageLevel)), Integer.valueOf(party.getPartyId()) });
/* 413 */       eim.registerParty(party, map, questID);
/* 414 */     } catch (ScriptException ex) {
/* 415 */       log.error("Event name : " + this.name + ", method Name : setup-partyid:\r\n" + ex);
/* 416 */     } catch (Exception ex) {

/* 418 */       startInstance_NoID(party, map, ex);
     }
   }





   public void startInstance_NoID(MapleParty party, MapleMap map) {
/* 427 */     startInstance_NoID(party, map, null);
   }






   public void startInstance_NoID(MapleParty party, MapleMap map, Exception old) {
     try {
/* 437 */       EventInstanceManager eim = (EventInstanceManager)this.iv.invokeFunction("setup", new Object[] { null });
/* 438 */       eim.registerParty(party, map);
/* 439 */     } catch (Exception ex) {
/* 440 */       log.error("Event name : " + this.name + ", method Name : setup-party:\r\n" + ex);
     }
   }







   public void startInstance(EventInstanceManager eim, String leader) {
     try {
/* 452 */       this.iv.invokeFunction("setup", new Object[] { eim });
/* 453 */       eim.setProperty("leader", leader);
/* 454 */     } catch (Exception ex) {
/* 455 */       log.error("Event name : " + this.name + ", method Name : setup-leader:\r\n" + ex);
     }
   }





   public void startInstance(MapleSquad squad, MapleMap map) {
/* 464 */     startInstance(squad, map, -1);
   }






   public void startInstance(MapleSquad squad, MapleMap map, int questID) {
/* 473 */     if (squad.getStatus() == 0) {
       return;
     }
/* 476 */     if (!squad.getLeader().isGM()) {
/* 477 */       checkSquad(squad, map);
     }
     try {
/* 480 */       EventInstanceManager eim = (EventInstanceManager)this.iv.invokeFunction("setup", new Object[] { squad.getLeaderName() });
/* 481 */       eim.registerSquad(squad, map, questID);
/* 482 */     } catch (Exception ex) {
/* 483 */       log.error("Event name : " + this.name + ", method Name : setup-squad:\r\n" + ex);
     }
   }

   private void checkSquad(MapleSquad squad, MapleMap map) {
/* 488 */     int mapid = map.getId();
/* 489 */     int chrSize = 0;
/* 490 */     for (String chr : squad.getMembers()) {
/* 491 */       MapleCharacter player = squad.getChar(chr);
/* 492 */       if (player != null && player.getMapId() == mapid) {
/* 493 */         chrSize++;
       }
     }
/* 496 */     if (chrSize < (squad.getType()).i) {
/* 497 */       squad.getLeader().dropMessage(5, "远征队中人员少于 " + (squad.getType()).i + " 人，无法开始远征任务。注意必须队伍中的角色在线且在同一地图。当前人数: " + chrSize);
       return;
     }
/* 500 */     if (this.name.equals("CWKPQ") && squad.getJobs().size() < 5) {
/* 501 */       squad.getLeader().dropMessage(5, "远征队中成员职业的类型小于5种，无法开始远征任务。");
     }
   }












   public void startInstance(MapleSquad squad, MapleMap map, String bossid) {
/* 517 */     startInstance(squad, map, bossid, true);
   }












   public void startInstance(MapleSquad squad, MapleMap map, String bossid, boolean checkSize) {
/* 532 */     if (squad.getStatus() == 0) {
       return;
     }
/* 535 */     if (!squad.getLeader().isGM() && checkSize) {
/* 536 */       checkSquad(squad, map);
     }
     try {
/* 539 */       EventInstanceManager eim = (EventInstanceManager)this.iv.invokeFunction("setup", new Object[] { squad.getLeaderName() });
/* 540 */       eim.registerSquad(squad, map, bossid);
/* 541 */     } catch (Exception ex) {
/* 542 */       log.error("Event name : " + this.name + ", method Name : setup-squad:\r\n" + ex);
     }
   }












   public void startInstance(MapleSquad squad, MapleMap map, String bossid, int memberSize) {
/* 558 */     if (squad.getStatus() == 0) {
       return;
     }
/* 561 */     if (!squad.getLeader().isGM()) {
/* 562 */       int mapid = map.getId();
/* 563 */       int chrSize = 0;
/* 564 */       for (String chr : squad.getMembers()) {
/* 565 */         MapleCharacter player = squad.getChar(chr);
/* 566 */         if (player != null && player.getMapId() == mapid) {
/* 567 */           chrSize++;
         }
       }
/* 570 */       if (chrSize < memberSize) {
/* 571 */         squad.getLeader().dropMessage(5, "远征队中人员少于 " + memberSize + " 人，无法开始远征任务。注意必须队伍中的角色在线且在同一地图。当前人数: " + chrSize);
         return;
       }
     }
     try {
/* 576 */       EventInstanceManager eim = (EventInstanceManager)this.iv.invokeFunction("setup", new Object[] { squad.getLeaderName() });
/* 577 */       eim.registerSquad(squad, map, bossid);
/* 578 */     } catch (Exception ex) {
/* 579 */       log.error("Event name : " + this.name + ", method Name : setup-squad:\r\n" + ex);
     }
   }





   public void warpAllPlayer(int from, int to) {
/* 588 */     MapleMap tomap = getMapFactory().getMap(to);
/* 589 */     MapleMap frommap = getMapFactory().getMap(from);
/* 590 */     if (tomap != null && frommap != null) {
/* 591 */       List<MapleCharacter> list = frommap.getCharactersThreadsafe();
/* 592 */       if (list != null && frommap.getCharactersSize() > 0) {
/* 593 */         for (MapleMapObject mmo : list) {
/* 594 */           ((MapleCharacter)mmo).changeMap(tomap, tomap.getPortal(0));
         }
       }
     }
   }




   public MapleMapFactory getMapFactory() {
/* 604 */     return getChannelServer().getMapFactory();
   }

   public MapleMap getMapFactoryMap(int mapid) {
/* 608 */     return getChannelServer().getMapFactory().getMap(mapid);
   }




   public OverrideMonsterStats newMonsterStats() {
/* 615 */     return new OverrideMonsterStats();
   }










   public final OverrideMonsterStats getOverrideMonsterStats(long hp, int mp, int exp) {
/* 628 */     return new OverrideMonsterStats(hp, mp, exp);
   }




   public List<MapleCharacter> newCharList() {
/* 635 */     return new ArrayList<>();
   }





   public MapleMonster getMonster(int id) {
/* 643 */     return MapleLifeFactory.getMonster(id);
   }

   public void spawnMonsterOnGroundBelow(MapleMap map, MapleMonster monster, int x, int y) {
/* 647 */     map.spawnMonsterOnGroundBelow(monster, new Point(x, y));
   }

   public void spawnDoJangMonster(MapleMap map, MapleMonster monster, int x) {
/* 651 */     Point point = new Point(x, 0);
/* 652 */     map.spawnMonsterWithEffect(monster, 15, point);
   }














   public MapleReactor getReactor(int id) {
/* 669 */     return new MapleReactor(MapleReactorFactory.getReactor(id), id);
   }





   public void broadcastShip(int mapid, int effect) {
/* 677 */     getMapFactory().getMap(mapid).broadcastMessage(MaplePacketCreator.boatPacket(effect));
   }

   public void sendBatShipEffect(int mapid, int effect) {
/* 681 */     broadcastShip(mapid, effect);
   }




   public void broadcastYellowMsg(String msg) {
/* 688 */     getChannelServer().broadcastPacket(MaplePacketCreator.yellowChat(msg));
   }




   public void broadcastServerMsg(String msg) {
/* 695 */     getChannelServer().broadcastPacket(MaplePacketCreator.serverNotice(6, msg));
   }
       public void broadcastNoticeWithoutPrefix(String msg) {
            getChannelServer().broadcastPacket(MaplePacketCreator.serverNotice(6, msg));
      }






   public void broadcastServerMsg(int type, String msg, boolean weather) {
/* 704 */     if (!weather) {
/* 705 */       getChannelServer().broadcastPacket(MaplePacketCreator.serverNotice(type, msg));
     } else {
/* 707 */       for (MapleMap load : getMapFactory().getAllMaps()) {
/* 708 */         if (load.getCharactersSize() > 0) {
/* 709 */           load.startMapEffect(msg, type);
         }
       }
     }
   }

   public void worldSpouseMessage(int type, String message) {
/* 716 */     if (type == 0 || type == 1 || (type >= 6 && type <= 42)) {
/* 717 */       WorldBroadcastService.getInstance().broadcastMessage(MaplePacketCreator.spouseMessage(type, message));
     } else {
/* 719 */       WorldBroadcastService.getInstance().broadcastMessage(MaplePacketCreator.serverNotice(6, message));
     }
   }

   public void broadcastEventMsg(int type, String text) {
/* 724 */     getChannelServer().broadcastPacket(UIPacket.getMapEffectMsg(text, type, 5000));
   }

   public final void worldMessageEffect(String message, int type, int time) {
/* 728 */     WorldBroadcastService.getInstance().broadcastMessage(UIPacket.getMapEffectMsg(message, type, time));
   }


   public void setWorldEvent() {
/* 733 */     for (int i = 0; i < eventChannel.length; i++) {
/* 734 */       eventChannel[i] = Randomizer.nextInt(ChannelServer.getAllInstances().size() - 4) + 2 + i;
     }
   }

   public boolean scheduleRandomEvent() {
/* 739 */     boolean bl2 = false;
/* 740 */     for (int anEventChannel : eventChannel) {
/* 741 */       bl2 |= scheduleRandomEventInChannel(anEventChannel);
     }
/* 743 */     return bl2;
   }

            public String getRandom(String s){
                return "";
            }
   public boolean scheduleRandomEventInChannel(int chz) {
/* 747 */     ChannelServer channelServer = getChannelServer();
/* 748 */     if (channelServer == null || channelServer.getEvent() > -1) {
/* 749 */       return false;
     }
/* 751 */     MapleEventType type = null;

/* 753 */     while (type == null) {
/* 754 */       MapleEventType[] arrayOfMapleEventType; int i; byte b; for (arrayOfMapleEventType = MapleEventType.values(), i = arrayOfMapleEventType.length, b = 0; b < i; ) { MapleEventType subtype = arrayOfMapleEventType[b];
/* 755 */         if (Randomizer.nextInt((MapleEventType.values()).length) != 0 || subtype == MapleEventType.OxQuiz) {
           b++; continue;
/* 757 */         }  type = subtype; }

     }

/* 761 */     String string = MapleEvent.scheduleEvent(type, channelServer);
/* 762 */     if (string.length() > 0) {
/* 763 */       broadcastYellowMsg(string);
/* 764 */       return false;
     }
/* 766 */     Timer.EventTimer.getInstance().schedule(() -> { if (channelServer.getEvent() >= 0) MapleEvent.setEvent(channelServer, true);  },180000L);




/* 771 */     return true;
   }

   public void setEventStart() {
/* 775 */     MapleEvent.setEvent(getChannelServer(), true);
   }

   public void setEvent(String event) {
/* 779 */     String string2 = MapleEvent.scheduleEvent(MapleEventType.getByString(event), getChannelServer());
/* 780 */     if (string2.length() > 0) {
/* 781 */       broadcastYellowMsg(string2);
     }
   }




   public void DoubleRateEvent(boolean start) {
/* 789 */     getChannelServer().setDoubleExp(start ? 2 : 1);
   }

   public byte[] showEffect(String effect) {
/* 793 */     return MaplePacketCreator.showEffect(effect);
   }

   public byte[] playSound(String sound) {
/* 797 */     return MaplePacketCreator.playSound(sound);
   }

   public byte[] getClock(int time) {
/* 801 */     return MaplePacketCreator.getClock(time);
   }

   public Connection getConnection() throws SQLException {
/* 805 */     return (Connection)DatabaseConnection.getInstance().getConnection();
   }

   public final void insertRanking(MapleCharacter player, String rankingname, int value) {
/* 809 */     RankingTop.getInstance().insertRanking(player, rankingname, value);
   }

   public final List<RankingTop.CharNameAndId> getRanking(String rankingname) {
/* 813 */     return RankingTop.getInstance().getRanking(rankingname);
   }

   public final List<RankingTop.CharNameAndId> getRanking(String rankingname, int previous) {
/* 817 */     return RankingTop.getInstance().getRanking(rankingname, previous);
   }

   public final List<RankingTop.CharNameAndId> getRanking(String rankingname, int previous, boolean repeatable) {
/* 821 */     return RankingTop.getInstance().getRanking(rankingname, previous, repeatable);
   }

   public boolean addById(MapleClient c, int itemId, short quantity, String gmLog) {
/* 825 */     return MapleInventoryManipulator.addById(c, itemId, quantity, null, null, 0L, 0, gmLog);
   }

   public boolean removeById(MapleClient c, int itemId, int quantity, boolean fromDrop, boolean consume) {
/* 829 */     return MapleInventoryManipulator.removeById(c, ItemConstants.getInventoryType(itemId), itemId, quantity, fromDrop, consume);
   }

   public MapleItemInformationProvider getItemInfo() {
/* 833 */     return MapleItemInformationProvider.getInstance();
   }

   public MapleMonsterInformationProvider getMonsterInfo() {
/* 837 */     return MapleMonsterInformationProvider.getInstance();
   }

   public final Item newItem(int id, byte position, short quantity) {
     Item ret=null;
/* 842 */     MapleInventoryType type = ItemConstants.getInventoryType(id);
/* 843 */     MapleItemInformationProvider ii = getItemInfo();
/* 844 */     if (type.equals(MapleInventoryType.EQUIP)) {
/* 845 */       Equip equip = ii.randomizeStats((Equip)ii.getEquipById(id));
     } else {
/* 847 */       ret = new Item(id, (short)position, quantity);
     }
/* 849 */     return ret;
   }

   public final ResultSet getDataSelectFromDB(String SQL) throws SQLException {
/* 853 */     return DatabaseConnection.getInstance().getConnection().prepareStatement(SQL).executeQuery();
   }

   public final PreparedStatement getDataInsertFromDB(String SQL) throws SQLException {
/* 857 */     return DatabaseConnection.getInstance().getConnection().prepareStatement(SQL);
   }

   public final void getDataUpdateFromDB(String SQL) throws SQLException {
/* 861 */     try (DruidPooledConnection con = DatabaseConnection.getInstance().getConnection()) {
/* 862 */       con.prepareStatement(SQL);
/* 863 */     } catch (SQLException sQLException) {}
   }
 }